home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / abc / FAQ / graphics < prev    next >
Encoding:
Text File  |  1994-04-01  |  3.1 KB  |  90 lines  |  [TEXT/R*ch]

  1. THE PROPOSED GRAPHICS FOR ABC
  2.  
  3. There is a proposed graphics interface for ABC. I won't describe it
  4. totally here (a good candidate for the next newsletter) but I'll just
  5. give an overview (the details may differ in the final version).
  6.  
  7. There are a number of functions that return 'pictures'. You may store
  8. these in the normal way in locations, return them from your own
  9. functions, and pass them as parameters to functions and commands in
  10. the usual way.
  11.  
  12. To quote from the design document, when considering the choice of primitives:
  13.  
  14.     Some objectives for the selection process are:
  15.     - minimize the number of functions; use monadic and dyadic versions
  16.       wherever useful;
  17.     - choose high level functions;
  18.     - combinations of operations should be meaningful;
  19.     - there should be no unnecessary user concern with coordinates;
  20.     - appropriate defaults should be chosen;
  21.     - creating simple pictures must be simple, yet creating
  22.       extensive pictures not too complicated;
  23.     - it must be user friendly, no unexpected effects should occur;
  24.     - the functions should be powerful and versatile;
  25.     - the functions should be logical and should match fair expectation;
  26.     - the functions should be easily extensible;
  27.     - the functions should have mnemonic names.
  28.     So, summarising: in the spirit of ABC .
  29.  
  30. The idea is that the functions give a useful default behaviour in as
  31. many cases as possible, but allow you complete control where you need it.
  32.  
  33. For instance:
  34.  
  35.     DISPLAY box text "Hello!"
  36.  
  37. will display the text "Hello!" centred on the screen with a box around
  38. it. Pictures can be combined, like:
  39.  
  40.     DISPLAY (box text "Hello") line (box text "there!")
  41.  
  42. to join the two boxes with a line.
  43.  
  44. If 'points' is a sequence of points (x, y), then
  45.  
  46.     DISPLAY polyline points
  47.  
  48. will draw a graph of the points by joining them up with lines; or
  49.  
  50.     DISPLAY box polyline points
  51.  
  52. to draw a box round the graph, or using the function 'pile' that
  53. positions two pictures one above the other, to add a caption:
  54.  
  55.     DISPLAY pile {[1]: box polyline points; [2]: text "Pretty!"}
  56.  
  57. 'row' works similarly, but horizontally.
  58.  
  59. To get an empty box of a certain size, you put it round an invisible
  60. object of the size required:
  61.  
  62.     HOW TO RETURN oblong(h, w): RETURN box (invisible line(w, h))
  63.  
  64. 'line(x, y)' produces a line from (0, 0) to relative position (x, y).
  65.  
  66. So, to draw a histogram of a sequence of numbers:
  67.  
  68.     HOW TO RETURN hist seq:
  69.         SHARE bar.width
  70.         PUT {} IN boxes
  71.         FOR x IN seq:
  72.             APPEND oblong(bar.width, x) TO boxes
  73.         RETURN row boxes
  74.  
  75.     >>> DISPLAY hist {1..10}
  76.  
  77. Now the big question: the implementation. Graphics is just one more of
  78. the million things Not Yet Implemented.
  79.  
  80. Lon Barfield has implemented much of the ABC graphics for our Next
  81. Project, Views, and I have a test version for ABC running in an xterm
  82. window under X windows.
  83.  
  84. The question for us is: do we put this in ABC, or do we add ABC to
  85. Views, and what priority should it have? Officially, ABC is not a
  86. research project anymore, and we're only doing 'maintenance' on the
  87. system. If only we had, let's say, 5 more programmers... If only
  88. programming-language research were glossy enough to attract Big
  89. Money... :-)
  90.